﻿## Get parameters
param 
(
    [string]$SiteUrl = $(throw '- Need parameter SiteUrl (e.g. "http://kaskelot")'),
	[string]$OwnerUserName = $(throw '- Need parameter OwnerUserName (e.g. "DOMAIN\Login")')
)

## check to ensure Microsoft.SharePoint.PowerShell is loaded if not using the SharePoint Management Shell 
$snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'} 
if ($snapin -eq $null) 
{    
	Write-Host "Loading SharePoint Powershell Snapin"    
	Add-PSSnapin "Microsoft.SharePoint.Powershell" 
}


[System.Reflection.Assembly]::LoadWithPartialName("Kaskelot.SP.Core")
[System.Reflection.Assembly]::LoadWithPartialName("Kaskelot.SP.Services")

$site = Get-SPSite $SiteUrl -ErrorAction SilentlyContinue
if ($site -eq $Null)
{
	$webTemplate = [Kaskelot.SP.Core.Constants+WebTemplates]::RootWebTemplate;
	$site = New-SPSite -Url $SiteUrl -Name "Kaskelot" -OwnerAlias $OwnerUserName -Language 1053 -Template $webTemplate
}

[Kaskelot.SP.Services.Setup.RootSetup]::Setup($SiteUrl)

./WCFClientServiceSettings.ps1